package com.hibernate.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.constraints.NotNull;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.javacommon.base.BaseEntity;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotBlank;

/**
 * 
 */

@Entity
@Table(name = "REPORT_EXIT_PAGE")
public class ReportExitPage extends BaseEntity implements java.io.Serializable{
	private static final long serialVersionUID = 5454155825314635342L;
	
	//alias
	public static final String TABLE_ALIAS = "关键流失页面";
	public static final String ALIAS_ID = "ID";
	public static final String ALIAS_AD_OWNER_ID = "广告客户ID";
	public static final String ALIAS_URL = "URL";
	public static final String ALIAS_PV = "流失PV";
	public static final String ALIAS_UV = "流失UV";
	public static final String ALIAS_LOG_DATE = "日期，精确到天";
	
	//date formats
	public static final String FORMAT_LOG_DATE = DATE_FORMAT;
	

	//可以直接使用: @Length(max=50,message="用户名长度不能大于50")显示错误消息
	//columns START
    /**
     * ID       db_column: ID 
     */ 	
	
	private Long id;
    /**
     * 广告客户ID       db_column: AD_OWNER_ID 
     */ 	
	@NotNull 
	private Long adOwnerId;
    /**
     * URL       db_column: URL 
     */ 	
	@NotBlank @Length(max=500)
	private java.lang.String url;
    /**
     * 流失PV       db_column: PV 
     */ 	
	@NotNull 
	private Long pv;
    /**
     * 流失UV       db_column: UV 
     */ 	
	@NotNull 
	private Long uv;
    /**
     * 日期，精确到天       db_column: LOG_DATE 
     */ 	
	@NotNull 
	private String logDate;
	//columns END
	
	/*****
	 * url的展示UV
	 */
	private Long showUv;
	
	@Column(name = "show_uv", unique = false, nullable = true, insertable = true, updatable = true, length = 20)
	public Long getShowUv() {
		return showUv;
	}

	public void setShowUv(Long showUv) {
		this.showUv = showUv;
	}
	
	public ReportExitPage(){
	}



	public ReportExitPage(
		Long id
	){
		this.id = id;
	}

	

	public void setId(Long value) {
		this.id = value;
	}
	
	@Id
	@GeneratedValue(generator = "paymentableGenerator")       
	@GenericGenerator(name = "paymentableGenerator", strategy = "native") 
	@Column(name = "ID", unique = true, nullable = false, insertable = true, updatable = true, length = 20)
	public Long getId() {
		return this.id;
	}
	
	@Column(name = "AD_OWNER_ID", unique = false, nullable = false, insertable = true, updatable = true, length = 20)
	public Long getAdOwnerId() {
		return this.adOwnerId;
	}
	
	public void setAdOwnerId(Long value) {
		this.adOwnerId = value;
	}
	
	@Column(name = "URL", unique = false, nullable = false, insertable = true, updatable = true, length = 500)
	public java.lang.String getUrl() {
		return this.url;
	}
	
	public void setUrl(java.lang.String value) {
		this.url = value;
	}
	
	@Column(name = "PV", unique = false, nullable = false, insertable = true, updatable = true, length = 20)
	public Long getPv() {
		return this.pv;
	}
	
	public void setPv(Long value) {
		this.pv = value;
	}
	
	@Column(name = "UV", unique = false, nullable = false, insertable = true, updatable = true, length = 20)
	public Long getUv() {
		return this.uv;
	}
	
	public void setUv(Long value) {
		this.uv = value;
	}
	
	@Column(name = "LOG_DATE", unique = false, nullable = false, insertable = true, updatable = true, length = 7)
	public String getLogDate() {
		return this.logDate;
	}
	
	public void setLogDate(String value) {
		this.logDate = value;
	}
	
	
//	private AdOwner adOwner;
//	public void setAdOwner(AdOwner adOwner){
//		this.adOwner = adOwner;
//	}
//	
//	@ManyToOne(cascade = {}, fetch = FetchType.LAZY)
//	@JoinColumns({
//		@JoinColumn(name = "AD_OWNER_ID",nullable = false, insertable = false, updatable = false) 
//	})
//	public AdOwner getAdOwner() {
//		return adOwner;
//	}

	public String toString() {
		return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
			.append("Id",getId())
			.append("AdOwnerId",getAdOwnerId())
			.append("Url",getUrl())
			.append("Pv",getPv())
			.append("Uv",getUv())
			.append("LogDate",getLogDate())
			.toString();
	}
	
	public int hashCode() {
		return new HashCodeBuilder()
			.append(getId())
			.toHashCode();
	}
	
	public boolean equals(Object obj) {
		if(obj instanceof ReportExitPage == false) return false;
		if(this == obj) return true;
		ReportExitPage other = (ReportExitPage)obj;
		return new EqualsBuilder()
			.append(getId(),other.getId())
			.isEquals();
	}
	@Transient
	@Override
	public String getTarget() {
		// TODO Auto-generated method stub
		return null;
	}
	@Transient
	@Override
	public Long getTargetId() {
		// TODO Auto-generated method stub
		return null;
	}
	@Transient
	@Override
	public String getTargetName() {
		// TODO Auto-generated method stub
		return null;
	}
}

